package com.book.controller;

import com.book.dto.BookImgPage;
import com.book.service.BookImgService;
import com.book.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * @author yicheng
 */
@RestController
@RequestMapping("/bookImg")
public class BookImgController {
    @Autowired
    private BookImgService bookImgService;

    @PostMapping("/getBookImg")
    private ResponseResult getBookImg(@RequestBody BookImgPage bookImgPage){
        return bookImgService.getBookImg(bookImgPage);
    }

    /**
     * 根据id删除书籍图片
     * @param id
     * @return
     */
    @GetMapping("/deleteImg")
    public ResponseResult deleteImg(@RequestParam int id){
        return bookImgService.deleteImg(id);
    }

    /**
     * 保存要给某本书上传的图片
     */
    @PostMapping("/saveImg")
    public ResponseResult saveImg(@RequestParam int bookId, @RequestBody List<String> imgAdd){
        return bookImgService.saveImg(bookId,imgAdd);
    }
}
